package com.ruoyi.project.oms.paeaAuTypeErrPointRel.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.oms.paeaAuTypeErrPointRel.domain.PaeaAuTypeErrPointRel;
import com.ruoyi.project.oms.paeaAuTypeErrPointRel.service.IPaeaAuTypeErrPointRelService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 监控类型差错点关系Controller
 *
 * @author 关晓强
 * @date 2020-03-14
 */
@Controller
@RequestMapping("/oms/paeaAuTypeErrPointRel")
public class PaeaAuTypeErrPointRelController extends BaseController
{
    private String prefix = "oms/paeaAuTypeErrPointRel";

    @Autowired
    private IPaeaAuTypeErrPointRelService paeaAuTypeErrPointRelService;

    @RequiresPermissions("oms:paeaAuTypeErrPointRel:view")
    @GetMapping()
    public String paeaAuTypeErrPointRel()
    {
        return prefix + "/paeaAuTypeErrPointRel";
    }

    /**
     * 查询监控类型差错点关系列表
     */
    @RequiresPermissions("oms:paeaAuTypeErrPointRel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaAuTypeErrPointRel paeaAuTypeErrPointRel)
    {
        startPage();
        List<PaeaAuTypeErrPointRel> list = paeaAuTypeErrPointRelService.list(new QueryWrapper<PaeaAuTypeErrPointRel>(paeaAuTypeErrPointRel));
        return getDataTable(list);
    }

    /**
     * 导出监控类型差错点关系列表
     */
    @RequiresPermissions("oms:paeaAuTypeErrPointRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaAuTypeErrPointRel paeaAuTypeErrPointRel)
    {
        List<PaeaAuTypeErrPointRel> list = paeaAuTypeErrPointRelService.list(new QueryWrapper<PaeaAuTypeErrPointRel>(paeaAuTypeErrPointRel));
        ExcelUtil<PaeaAuTypeErrPointRel> util = new ExcelUtil<PaeaAuTypeErrPointRel>(PaeaAuTypeErrPointRel.class);
        return util.exportExcel(list, "paeaAuTypeErrPointRel");
    }

    /**
     * 新增监控类型差错点关系
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存监控类型差错点关系
     */
    @RequiresPermissions("oms:paeaAuTypeErrPointRel:add")
    @Log(title = "监控类型差错点关系", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaAuTypeErrPointRel paeaAuTypeErrPointRel)
    {
        return toAjax(paeaAuTypeErrPointRelService.saveOrUpdate(paeaAuTypeErrPointRel));
    }

    /**
     * 修改监控类型差错点关系
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaAuTypeErrPointRel paeaAuTypeErrPointRel = paeaAuTypeErrPointRelService.getById(id);
        mmap.put("paeaAuTypeErrPointRel", paeaAuTypeErrPointRel);
        return prefix + "/edit";
    }

    /**
     * 修改保存监控类型差错点关系
     */
    @RequiresPermissions("oms:paeaAuTypeErrPointRel:edit")
    @Log(title = "监控类型差错点关系", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaAuTypeErrPointRel paeaAuTypeErrPointRel)
    {
        return toAjax(paeaAuTypeErrPointRelService.saveOrUpdate(paeaAuTypeErrPointRel));
    }

    /**
     * 删除监控类型差错点关系
     */
    @RequiresPermissions("oms:paeaAuTypeErrPointRel:remove")
    @Log(title = "监控类型差错点关系", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaAuTypeErrPointRelService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
